/*
	ViewGame.h
	(c)2000 Palestar, Richard Lyle
*/

#ifndef VIEWGAME_H
#define VIEWGAME_H

#include "System/Messages.h"
#include "Gui3d/WindowView.h"
#include "Gui3d/ButtonPopup.h"
#include "Game/NounUnit.h"
#include "Interface/BarHUD.h"
#include "Standard/Settings.h"
#include "Interface/GameDocument.h"
#include "Interface/WindowEnhancement.h"

//----------------------------------------------------------------------------

class ViewGame : public WindowView::View
{
public:
	DECLARE_WIDGET_CLASS();

	// Types
	typedef Reference< ViewGame >	Ref;

	enum Mode
	{
		TACTICAL,			// tactical mode
		NAVIGATION,			// navigation mode
		PLANET,				// planet mode
	};
	enum ChatMode
	{
		FACTION,
		FLEET,
		YELL,
		TARGET,
	};
	// Construction
						ViewGame();
	// View interface
	void				onActivate();
	void				onDeactivate();
	void				onUpdate( float t );
	bool				onMessage( const Message & msg );
	void				onDocumentUpdate();

	void				onRender( RenderContext & context, 
							const RectInt & window );

	void				addPotentialTip(unsigned int a_id);

	// {{BEGIN_DATA
	WindowEnhancement *			m_pEnhancementWindow;
	WindowText *				m_pTipHelpText;
	WindowText *				m_pTipHelpTitle;
	NodeWindow *				m_pTipHelpBox;
	WindowButton *				m_pButtonTip[5];
	WindowButton *				m_pMessageBoxCANCEL;
	WindowButton *				m_pMessageBoxOK;
	WindowText *				m_pMessageBox;
	WindowButton *				m_pButtonCancelOrder;
	ButtonPopup *				m_pPopupTargetButtons;
	WindowButton *				m_pButtonRightConsole;
	NodeWindow *				m_pTargetFrame;
	NodeWindow *				m_pLayoutTargetButtons;
	WindowButton *				m_pButtonShadow;
	WindowButton *				m_pButtonScoutMission;
	WindowButton *				m_pButtonDefendMission;
	WindowButton *				m_pButtonCaptureMission;
	WindowButton *				m_pButtonAttackMission;
	WindowButton *				m_pButtonTarget;
	WindowButton *				m_pButtonYell;
	WindowButton *				m_pButtonFaction;
	WindowButton *				m_pButtonFleet;
	WindowButton *				m_pButtonNextTarget;
	WindowButton *				m_pButtonUpTarget;
	WindowButton *				m_pButtonOrderRaze;
	WindowButton *				m_pButtonOrderDefend;
	WindowButton *				m_pButtonOrderAttack;
	WindowButton *				m_pButtonNext;
	WindowButton *				m_pButtonPrev;
	WindowButton *				m_pButtonRepairNow;
	WindowButton *				m_pButtonRepairLast;
	WindowButton *				m_pButtonAutoDefense;
	WindowButton *				m_pButtonUseStructure;
	WindowButton *				m_pButtonApplyEnhancement;
	WindowText *				m_pTextConfirm;
	NodeWindow *				m_pWindowConfirm;
	WindowButton *				m_pButtonSendChat;
	WindowEdit *				m_pEditTransferCredits;
	NodeWindow *				m_pWindowTransferCredits;
	WindowButton *				m_pButtonTransferCredits;
	WindowButton *				m_pButtonPlanet;
	WindowButton *				m_pButtonUnlock;
	WindowButton *				m_pButtonLock;
	NodeWindow *				m_pViewPlanet;
	NodeWindow *				m_pTargetButtons2;
	NodeWindow *				m_pViewTrade;
	WindowButton *				m_pButtonJettison;
	WindowButton *				m_pButtonCamera;
	WindowButton *				m_pButtonContinue;
	WindowButton *				m_pButtonPause;
	WindowText *				m_pSignatureText;
	BarHUD *					m_pSignatureBar;
	NodeWindow *				m_pRightConsole;
	NodeWindow *				m_pLeftConsole;
	WindowEdit *				m_pChatEdit;
	NodeWindow *				m_pHelpWindow;
	WindowButton *				m_pButtonDisband;
	WindowButton *				m_pButtonScrap;
	WindowButton *				m_pButtonLoad;
	WindowButton *				m_pButtonOrbit;
	WindowButton *				m_pButtonFollow;
	WindowText *				m_pTargetDescription;
	WindowButton *				m_pButtonNavigation;
	WindowButton *				m_pButtonHelp;
	NodeWindow *				m_pIncomingMessages;
	WindowText *				m_pShipStatusText;
	WindowText *				m_pEnergyText;
	BarHUD *					m_pEnergyBar;
	WindowText *				m_pHullText;
	BarHUD *					m_pHullBar;
	NodeWindow *				m_pViewNavigation;
	NodeWindow *				m_pViewTactical;
	// END_DATA}}

	// {{BEGIN_MSG
	bool				onButtonRemoveEnhancement(const Message & msg);
	bool				onButtonEnhUp(const Message & msg);
	bool				onButtonShowEnhancements(const Message & msg);
	bool				onButtonApplyEnhancement(const Message & msg);
	bool				onTipHelpOK(const Message & msg);
	bool				onButtonTip1(const Message & msg);
	bool				onButtonTip2(const Message & msg);
	bool				onButtonTip3(const Message & msg);
	bool				onButtonTip4(const Message & msg);
	bool				onButtonTip5(const Message & msg);
	bool				onMessageBoxCANCEL(const Message & msg);
	bool				onMessageBoxOK(const Message & msg);
	bool				onButtonAbortOrder(const Message & msg);
	bool				onButtonCancelOrder(const Message & msg);
	bool				onButtonOrderRaze(const Message & msg);
	bool				onButtonOrderDefend(const Message & msg);
	bool				onButtonOrderAttack(const Message & msg);
	bool				onButtonTargetYard(const Message & msg);
	bool				onButtonTargetPort(const Message & msg);
	bool				onButtonTargetSupply(const Message & msg);
	bool				onButtonTargetJumpGate(const Message & msg);
	bool				onButtonTargetDistress(const Message & msg);
	bool				onButtonTargetFriendly(const Message & msg);
	bool				onButtonTargetEnemy(const Message & msg);
	bool				onButtonShadow(const Message & msg);
	bool				onButtonScoutMission(const Message & msg);
	bool				onButtonDefendMission(const Message & msg);
	bool				onButtonCaptureMission(const Message & msg);
	bool				onButtonAttackMission(const Message & msg);
	bool				onButtonTarget(const Message & msg);
	bool				onButtonYell(const Message & msg);
	bool				onButtonFaction(const Message & msg);
	bool				onButtonFleet(const Message & msg);
	bool				onButtonNextTarget(const Message & msg);
	bool				onButtonUpTarget(const Message & msg);
	bool				onButtonNext(const Message & msg);
	bool				onButtonPrev(const Message & msg);
	bool				onButtonRepairNow(const Message & msg);
	bool				onButtonRepairLast(const Message & msg);
	bool				onButtonAutoDefense(const Message & msg);
	bool				onButtonUseStructure(const Message & msg);
	bool				onButtonConfirmCancel(const Message & msg);
	bool				onButtonConfirmOkay(const Message & msg);
	bool				onEditTransferCredits(const Message & msg);
	bool				onButtonTransferCredits(const Message & msg);
	bool				onButtonPlanet(const Message & msg);
	bool				onButtonUnlock(const Message & msg);
	bool				onButtonLock(const Message & msg);
	bool				onButtonJettison(const Message & msg);
	bool				onButtonCamera(const Message & msg);
	bool				onButtonContinue(const Message & msg);
	bool				onButtonPause(const Message & msg);
	bool				onChatEdit(const Message & msg);
	bool				onButtonDisband(const Message & msg);
	bool				onButtonScrap(const Message & msg);
	bool				onButtonLoad(const Message & msg);
	bool				onButtonOrbit(const Message & msg);
	bool				onButtonFollow(const Message & msg);
	bool				onButtonNavigation(const Message & msg);
	bool				onButtonHelp(const Message & msg);
	// END_MSG}}

	// static
	static void			addTip(unsigned int a_id);

private:
	// Accessors
	Noun *				myTarget() const;			// resolves NounDropTarget/NounBeacon targets to the correct object
	NounGadget *		myGadgetTarget() const;		

	// Mutators
	void				changeMode( Mode mode );

	bool				isTipPending(unsigned int a_id);
	void				checkForPendingTips();
	WindowButton *		getFreeTipButton();
	// Static
	static void			hideAllButtons( BaseNode * pNode );
	static bool			isValidGroup( NounShip * pShip, dword group );
	
	// Data
	GameDocument *		m_pDoc;				// our client object
	Mode				m_Mode;				// our current mode
	ChatMode			m_ChatMode;			// current chat mode
	float				m_CollisionCheck;

	bool				m_CameraFromNavigation;
	bool				m_HideTips;

	Noun::wRef			m_LastTarget;

	Array<unsigned int> m_PendingTipList;
	Array<unsigned int> m_ViewedTips;
	Settings *			m_pSettings;

	NounStructure::wRef	m_ConfirmScrap;
	NounUnit::wRef		m_ConfirmDisband;
	Noun::wRef			m_ConfirmJettison;
	NounStructure::wRef	m_ConfirmUseStructure;

	ButtonEnhancement::wRef
						m_ConfirmRemoveEnhancement;

	// toggling Enhancements
	int					m_CurrentEnhancement;
	float				m_nRotatingEnhancementTick;

public:
	static ViewGame	*	m_pViewGame;
};

//----------------------------------------------------------------------------



#endif

//----------------------------------------------------------------------------
// EOF
